﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Physio10Context;
using DatabaseManager;

namespace Physio_Clinic
{
    public partial class MedicalReportEdit : System.Web.UI.Page
    {
        public Booking booking = null;
        public Qf8soUser currentUser = null;

        protected void Page_Load(object sender, EventArgs e)
        {
            booking = (Booking)(Session["Booking"]);

            if (Session["currentUser"] != null)
            {
                currentUser = (Qf8soUser)Session["currentUser"];
            }

            if (booking != null)
            {
                Username.Text = booking.UserName;
                AppointmentTime.Text = booking.AppointmentTime.ToString();
                EndappointmentTime.Text = booking.EndappointmentTime.ToString();
                //DoctorID.Text = booking.DoctorId.ToString();
                UserId.Text = booking.UserId.ToString();
                BookId.Text = booking.BookId.ToString();
            }
        }

        protected void Submit_OnClick(object sender, EventArgs e)
        {
            if (booking != null)
            {
                //booking.DoctorResultPicture = 
                //PersistentManager.Instance.Update(booking);
                //PersistentManager.Instance.Save();
                if (MyFile.PostedFile.ContentLength != 0)
                {
                    string extension = System.IO.Path.GetExtension(MyFile.PostedFile.FileName);
                    string trailingPath = "scanImage\\" + booking.BookId.ToString() + ".jpg";
                    MyFile.PostedFile.SaveAs(System.IO.Path.Combine(Server.MapPath(" "), trailingPath));
                }
                Response.Redirect("MedicalReportListEdit.aspx");
            }
        }

        protected void Cancel_OnClick(object sender, EventArgs e)
        {
            if (booking != null)
            {
                Response.Redirect("MedicalReportListEdit.aspx");
            }
        }

    }
}